package com.lz.controller.zhy;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.lz.entity.Employee;
import com.lz.service.zhy.EmployeeInfoService;

@Controller
public class EmployeeInfoHandler {
    
	 // 使用@Autowired注解注入EmployeeInfoServiceImpl实例
		@Autowired
		EmployeeInfoService employeeInfoService;
		
		@RequestMapping("/zhuye")
		public String login(){
			return "homepage";
		}
		
		@RequestMapping("/aaa")
		public String employeeLogin1(){
		   System.out.println("123132");
			return "login";
		}
		
		@RequestMapping(value="/login",method=RequestMethod.POST)
		public String employeeLogin(Employee employee,Model model,HttpServletRequest request){
			
			HttpSession session = request.getSession();
			
			
			Employee employee2 = employeeInfoService.employee(employee);
			if(employee2==null){
				System.out.println("没找到");
				return "login";
			}else{
				session.setAttribute("employee", employee2);
				
			}
			System.out.println("找到了");
			model.addAttribute("employee2",employee2.getRoleId());
			return "alerts";
		}
		
		
		
}
